package com.lemon.boot.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.concurrent.TimeUnit;

/**
 * @author 李猛
 * @datetime 2024/9/18 14:36
 * @description TODO
 */
@Getter
@AllArgsConstructor
public enum InviteUserTime {
    FIVE_MINUTES(5, TimeUnit.MINUTES, "五分钟"),
    HALF_HOUR(30, TimeUnit.MINUTES, "半小时"),
    ONE_HOUR(1, TimeUnit.HOURS, "一小时"),
    TOW_HOUR(2, TimeUnit.HOURS, "两小时"),
    ONE_DAY(1, TimeUnit.DAYS, "一天"),
    ONE_WEEK(7, TimeUnit.DAYS, "一周"),
    ONE_MONTH(30, TimeUnit.DAYS, "一个月");

    private final long time;
    private final TimeUnit unit;
    private final String desc;

    public long getTimeByUnit() {
        switch (getUnit()) {
            case MINUTES:
                return getTime() * 60;
            case HOURS:
                return getTime() * 60 * 60;
            case DAYS:
                return getTime() * 60 * 60 * 24;
            default:
                return getTime();
        }
    }
}
